package com.ysccc.shares.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;

import com.ysccc.spring.boot.starter.sqldb.entity.DefaultStategyEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "shares_detail", indexes = @Index(columnList = "shares_id, day", name = "i_shares_detail", unique = true))
public class SharesDaily extends DefaultStategyEntity {

	private static final long serialVersionUID = 1L;
	
	/** 日期 */
	private Date day;
	
	/** 昨日收盘价 */
	private Double lastDayEndPrice;
	
	/** 今日开盘价 */
	private Double startPrice;
	
	/** 今日收盘价 */
	private Double endPrice;
	
	/** 今日最高价 */
	private Double maxPrice;
	
	/** 今日最低价 */
	private Double minPrice;
	
	/** 成交的股票数 */
	private Long tradeNum;
	
	/** 成交金额 */
	private Long tradeAmount;
	
	/** 涨跌金额 */
	private Double upDownAmount;
	
	/** 涨跌比例 */
	private Double upDownRate;
	
	/** 股票 */
	@ManyToOne
	@JoinColumn(name = "shares_id", foreignKey = @ForeignKey(name = "fk_shares_detail"))
	@Fetch(FetchMode.SELECT)
	@LazyToOne(LazyToOneOption.PROXY)
	private Shares shares;
}
